]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/keyboard: Switch input source on special modifiers accelerator
authorRui Matos <tiagomatos@gmail.com>
Fri, 29 Mar 2013 01:35:32 +0000 (02:35 +0100)
committerRui Matos <tiagomatos@gmail.com>
Mon, 27 May 2013 12:05:51 +0000 (14:05 +0200)
This simply mimics the X server's layout switching behavior by
advancing to the next input source and wrapping around.

https://bugzilla.gnome.org/show_bug.cgi?id=697008

js/ui/status/keyboard.js

index 0dbcc4ac4645d19df60692604cfc2cb59fb62d4f..903afe2dc5b870ffa953b9a9f16b90623f84543a 100644 (file)
@@ -398,6 +398,8 @@ const InputSourceIndicator = new Lang.Class({
                                                          });
         this._keyboardManager.g_default_timeout = MAX_INPUT_SOURCE_ACTIVATION_TIME;
 
+        global.display.connect('modifiers-accelerator-activated', Lang.bind(this, this._modifiersSwitcher));
+
         this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
         this._showLayoutItem = this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, this._showLayout));
 
@@ -431,6 +433,28 @@ const InputSourceIndicator = new Lang.Class({
         this._inputSourcesChanged();
     },
 
+    _modifiersSwitcher: function() {
+        let sourceIndexes = Object.keys(this._inputSources);
+        if (sourceIndexes.length == 0) {
+            releaseKeyboard();
+            return true;
+        }
+
+        let is = this._currentSource;
+        if (!is)
+            is = this._inputSources[sourceIndexes[0]];
+
+        let nextIndex = is.index + 1;
+        if (nextIndex > sourceIndexes[sourceIndexes.length - 1])
+            nextIndex = 0;
+
+        while (!(is = this._inputSources[nextIndex]))
+            nextIndex += 1;
+
+        is.activate();
+        return true;
+    },
+
     _switchInputSource: function(display, screen, window, binding) {
         if (this._mruSources.length < 2)
             return;